/*
 * =====================================================================================
 *
 *       Filename:  enumerateAB.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  12/08/2010 04:33:18 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ken Chen (Ken), chen_kenz@emc.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#include <vector> 
#include <string>
#include <iterator>
#include <iostream> 

using namespace std;

vector<string> enumerateAB( int n )
{
  vector<string> abStrs;
  int k = ( 1 << n ) ;

  for( int i = 0; i < k; ++i )
  {
    string ab("");
    for( int pos = 0; pos < n; ++pos ) 
    {
      if( (1 << pos) & i )
      {
        ab.append("B");
      }
      else
      {
        ab.append("A");
      }
    }
    abStrs.push_back( ab );  
  }

  return abStrs;
}


int main( int argc, char* argv[] )
{
  vector<string> abs1( enumerateAB(1) );
  copy( abs1.begin(), abs1.end(), ostream_iterator<string>( cout, "\n" ) );

  vector<string> abs2( enumerateAB(2) );
  copy( abs2.begin(), abs2.end(), ostream_iterator<string>( cout, "\n" ) );

  vector<string> abs3( enumerateAB(4) );
  copy( abs3.begin(), abs3.end(), ostream_iterator<string>( cout, "\n" ) );

  return 0;
}
